/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/


#ifndef MK_RTSP_SERVER_H
#define MK_RTSP_SERVER_H
#include "MkTcp/MkTcpServer.h"
#include "MkMedia/MkMediaSource.h"
#include "MkMedia/MkMediaConsumer.h"
#include "MkRtspUtil.h"

class CMkRtpUdpServer;
typedef MkFunction<Uint32(MkString& UserName, MkString& Password)> GetAuthCallback;
class MkApi CMkRtspServer : public CMkTcpServer
{
public:
    CMkRtspServer(CMkEventPool* pEventPool, CMkTimer* pTimer, MkVector<CMkRtpUdpServer*>& VecRtpUdpServer, const GetAuthCallback& GetAuthCb, const MkMediaCallbacks& MediaCallbacks);
    ~CMkRtspServer();
    void SetRealm(const MkString& Realm) { m_Realm = Realm; }
    const MkString& GetRealm() { return m_Realm; }
    const MkVector<MkRtspMethod>& GetSupportMethods() const { return m_VecSupportMethods; }

private:
    CMkRtpUdpServer* GetFreeRtpUdpServer() const;
    CMkTcpSession* CreateNewSession(CMkEvent *pEvent, CMkTimer* pTimer) override;
private:
    MkVector<CMkRtpUdpServer*>               m_VecRtpUdpServer;
    GetAuthCallback                          m_GetAuthCb;
    MkMediaCallbacks                         m_MediaCallbacks;
    MkString                                 m_Realm;
    MkVector<MkRtspMethod>                   m_VecSupportMethods;
};







#endif